package com.ruoyi.teaching.controller;

import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.teaching.domain.TeachingTracking;
import com.ruoyi.teaching.service.ITeachingTrackingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 教学跟踪Controller
 * 
 * @author thl
 * @date 2024-01-05
 */
@RestController
@RequestMapping("/tracking")
public class TeachingTrackingController extends BaseController
{
    @Autowired
    private ITeachingTrackingService teachingTrackingService;
//    @Autowired
//    private StudentFeignClient studentFeignClient;

    /**
     * 添加学生问题记录
     * @param teachingTracking
     * @return
     */
//    @GetMapping("/AddRecords")
//    public AjaxResult AddRecords(@PathVariable("id")Long id){
//        AjaxResult info = studentFeignClient.getInfo(id);
//        return AjaxResult.success("成功",info);
//    }
    /**
     * 查询教学跟踪列表
     */
    @RequiresPermissions("teaching:tracking:list")
    @GetMapping("/list")
    public TableDataInfo list(TeachingTracking teachingTracking)
    {
        startPage();
        List<TeachingTracking> list = teachingTrackingService.selectTeachingTrackingList(teachingTracking);
        return getDataTable(list);
    }

    /**
     * 导出教学跟踪列表
     */
    @RequiresPermissions("teaching:tracking:export")
    @Log(title = "教学跟踪", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TeachingTracking teachingTracking)
    {
        List<TeachingTracking> list = teachingTrackingService.selectTeachingTrackingList(teachingTracking);
        ExcelUtil<TeachingTracking> util = new ExcelUtil<TeachingTracking>(TeachingTracking.class);
        util.exportExcel(response, list, "教学跟踪数据");
    }

    /**
     * 获取教学跟踪详细信息
     */
    @RequiresPermissions("teaching:tracking:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(teachingTrackingService.selectTeachingTrackingById(id));
    }

    /**
     * 新增教学跟踪
     */
    @RequiresPermissions("teaching:tracking:add")
    @Log(title = "教学跟踪", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TeachingTracking teachingTracking)
    {
        return toAjax(teachingTrackingService.insertTeachingTracking(teachingTracking));
    }

    /**
     * 修改教学跟踪
     */
    @RequiresPermissions("teaching:tracking:edit")
    @Log(title = "教学跟踪", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TeachingTracking teachingTracking)
    {
        return toAjax(teachingTrackingService.updateTeachingTracking(teachingTracking));
    }

    /**
     * 删除教学跟踪
     */
    @RequiresPermissions("teaching:tracking:remove")
    @Log(title = "教学跟踪", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(teachingTrackingService.deleteTeachingTrackingByIds(ids));
    }
}
